import { watcher } from '@feng3d/watcher';
import { BufferGeometry3D } from 'feng3d-three';
import { TeapotGeometry } from '../thirdparty/three/imports';

export class TeapotGeometry3D extends BufferGeometry3D
{
    size?: number;
    segments?: number;
    bottom?: boolean;
    lid?: boolean;
    body?: boolean;
    fitLid?: boolean;
    blinn?: number;

    get _geometry()
    {
        if (!this.__geometry)
        {
            this.__geometry = new TeapotGeometry(this.size, this.segments, this.bottom, this.lid, this.body, this.fitLid, this.blinn);
        }

        return this.__geometry;
    }
    declare protected __geometry: TeapotGeometry;

    constructor()
    {
        super();

        watcher.watchs(this as TeapotGeometry3D, ['size', 'segments', 'bottom', 'lid', 'body', 'fitLid', 'blinn'], this._invalidate, this);
    }

    destroy()
    {
        watcher.unwatchs(this as TeapotGeometry3D, ['size', 'segments', 'bottom', 'lid', 'body', 'fitLid', 'blinn'], this._invalidate, this);
    }
}
